<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/mytags.jsp"%>
<html>
<head>

<%@ include file="/common/easyui.jsp"%>
<%@ include file="/common/jquery-zTree.jsp"%>

<script type="text/javascript">
	function load(){
		$.getJSON("${ctx}/adminManage/auto/autoDbTable/loadTable.do",{
			dbId:'${param.dbId}',
			tableName:autoDbTableForm.tableName.value
		},function(json) {
			if(json.result){
				var autoDbTableModel=json.obj.autoDbTableModel;
				var list=json.obj.list;
				
				autoDbTableForm.tableComments.value=autoDbTableModel.tableComments;
				autoDbTableForm.className.value=autoDbTableModel.className;
				autoDbTableForm.templateId.value=autoDbTableModel.templateId;
				autoDbTableForm.tablePkNum.value=autoDbTableModel.tablePkNum;
				autoDbTableForm.tablePkName.value=autoDbTableModel.tablePkName;
				autoDbTableForm.tablePkType.value=autoDbTableModel.tablePkType;
				autoDbTableForm.tablePkValue.value=autoDbTableModel.tablePkValue;
				
				$('#dataTable').datagrid('loadData',list);
		        $("#dataTable").datagrid('beginEdit',0);
			}else{
				alert(json.msg);
			}
		});
	}
</script>
<link rel="stylesheet" href="${ctx}/plug-in/Validform/css/style.css" type="text/css"/>
<link rel="stylesheet" href="${ctx}/plug-in/Validform/css/tablefrom.css" type="text/css"/>
</head>

<body class="easyui-layout">
<form action="" method="post" name="autoDbTableForm">
<div region="north" title="数据库表管理" border="false" style="height: 200px">
	<table class="formtable">
		<tr>
			<td width="15%" align="right"><label class="Validform_label">表名：</label></td>
			<td width="35%" class="value">
				<input type="text" name="tableName" value="auto_dictionary"/>
				<input type="button" value="加载" onclick="load()"/>
			</td>
			<td width="15%" align="right"><label class="Validform_label">表描述：</label></td>
			<td width="35%" class="value" colspan="3"><input type="text" name="tableComments" /> </td>
		</tr>
		<tr>
			<td align="right"><label class="Validform_label">类名：</label></td>
			<td class="value">
				<input type="text" name="className" />
			</td>
			<td align="right"><label class="Validform_label">模板：</label></td>
			<td class="value">
				<input type="text" name="templateId" />
			</td>
		</tr>
		<tr>
			<td align="right"><label class="Validform_label">主键数：</label></td>
			<td class="value">
				<input type="text" name="tablePkNum" />
			</td>
			<td align="right"><label class="Validform_label">主键名：</label></td>
			<td class="value">
				<input type="text" name="tablePkName" />
			</td>
		</tr>
		<tr>
			<td align="right"><label class="Validform_label">主键类型：</label></td>
			<td class="value">
				<input type="text" name="tablePkType" />
			</td>
			<td align="right"><label class="Validform_label">主键取值：</label></td>
			<td class="value">
				<input type="text" name="tablePkValue" />
			</td>
		</tr>
	</table>
</div>
<div region="center" border="false">
	<table id="dataTable" class="easyui-datagrid" title="数据库字段" style="width:100%;height:100%"
		data-options="fitColumns:true,
					singleSelect:true,
					onClickRow:function(index,row){  
				        row.editing = true;  
				        $('#dataTable').datagrid('refreshRow', index);  
				    }">
		<thead>
            <tr>
                <th data-options="field:'sqlColumnName',editor:{type:'text'}">字段名称</th>
                <th data-options="field:'sqlRemarks',editor:{type:'text'}">字段描述</th>
                <th data-options="field:'classColumnName',editor:{type:'text'}">属性名称</th>
                <th data-options="field:'sqlDataType'">字段类型</th>
                <th data-options="field:'classDataType'">属性类型</th>
                <th data-options="field:'sqlColumnSize'">字段长度</th>
                <th data-options="field:'sqlDecimalDigits'">小数部分</th>
                <th data-options="field:'sqlNullAble'">是否允许为空</th>
                <th data-options="field:'sqlColumnDef'">默认值</th>
                <th data-options="field:'isDatetimeColumn'">是否时间类型</th>
            </tr>
        </thead>
	</table>
</div>	
</form>
</body>
</html>